 IDENTIFICATION              DIVISION.                            
 PROGRAM-ID.                 AAGC0103.
 ENVIRONMENT                 DIVISION.                            
 CONFIGURATION               SECTION.                             
 SOURCE-COMPUTER.            IBM.                                 
 OBJECT-COMPUTER.            IBM.                                 
 INPUT-OUTPUT                SECTION.                             
 FILE-CONTROL.                                                    
     SELECT  FLIN0001    ASSIGN  TO  INCK0001.                    
     SELECT  FLIN0002    ASSIGN  TO  INCK0002.                    
     SELECT  FLOT0001    ASSIGN  TO  OTCK0001.                    
     SELECT  FLOT0002    ASSIGN  TO  OTCK0002.                    
 DATA                        DIVISION.                            
 FILE                        SECTION.                             
 FD  FLIN0001                                                     
     LABEL RECORD    IS  STANDARD                                 
     RECORDING MODE  IS  F                                        
     BLOCK CONTAINS  0   RECORDS.                                 
 01  I1.                                                          
       03  A103A01               PIC 999.                       
       03  A103A02               PIC 9(02).                       
       03  A103A03               PIC G(09)  DISPLAY-1.            
       03  A103A04               PIC 9(05).                       
       03  A103A05               PIC 9(05).                       
       03  A103A06               PIC 9(05).                       
       03  A103A07               PIC 9(05).                       
       03  A103A08               PIC 9(05).                       
       03  A103A09               PIC 9(05).                       
       03  A103A10               PIC 9(05).                       
       03  A103A11               PIC 9(05).                       
       03  A103A12               PIC 9(05).                       
       03  A103A13               PIC 9(01).                       
       03  A103A14               PIC 9(07).                       
       03  A103A15               PIC X(74).                       
 FD  FLIN0002                                                     
     LABEL RECORD    IS  STANDARD                                 
     RECORDING MODE  IS  F                                        
     BLOCK CONTAINS  0   RECORDS.                                 
 01  I2.                                                          
       03  A103001               PIC 9(03).                       
       03  A103002               PIC 9(02).                       
       03  A103003               PIC G(09)  DISPLAY-1.            
       03  A103004               PIC 9(05).                       
       03  A103005               PIC 9(05).                       
       03  A103006               PIC 9(05).                       
       03  A103007               PIC 9(05).                       
       03  A103008               PIC 9(05).                       
       03  A103009               PIC 9(05).                       
       03  A103010               PIC 9(05).                       
       03  A103011               PIC 9(05).                       
       03  A103012               PIC 9(05).                       
       03  A103013               PIC 9(01).                       
       03  A103014               PIC 9(07).                       
       03  A103015               PIC X(74).                       
 FD  FLOT0001                                                     
     LABEL RECORD    IS  STANDARD                                 
     RECORDING MODE  IS  F                                        
     BLOCK CONTAINS  0   RECORDS.                                 
 01  O1.                                                          
       03  A104A001              PIC 9(03).                       
       03  A104A002              PIC 9(02).                       
       03  A104A003              PIC G(09)  DISPLAY-1.            
       03  A104A004              PIC 9(07).                       
       03  A104A005              PIC 9(05).                       
       03  A104A006              PIC 9(05).                       
       03  A104A007              PIC 9(05).                       
       03  A104A008              PIC 9(05).                       
       03  A104A009              PIC 9(05).                       
       03  A104A010              PIC 9(05).                       
       03  A104A011              PIC 9(05).                       
       03  A104A012              PIC 9(05).                       
       03  A104A013              PIC 9(05).                       
       03  A104A014              PIC 9(01).                       
       03  A104A015              PIC 9(3)V9(3).                   
       03  A104A016              PIC 9(3)V9(3).                   
       03  A104A017              PIC 9(3)V9(3).                   
       03  A104A018              PIC 9(3)V9(3).                   
       03  A104A019              PIC 9(3)V9(3).                   
       03  A104A020              PIC 9(3)V9(3).                   
       03  A104A021              PIC X(88).                       
 FD  FLOT0002                                                     
     LABEL RECORD    IS  STANDARD                                 
     RECORDING MODE  IS  F                                        
     BLOCK CONTAINS  0   RECORDS.                                 
 01  O2.                                                          
       03  A104001               PIC 9(03).                       
       03  A104002               PIC 9(02).                       
       03  A104003               PIC G(09)  DISPLAY-1.            
       03  A104004               PIC 9(07).                       
       03  A104005               PIC 9(05).                       
       03  A104006               PIC 9(05).                       
       03  A104007               PIC 9(05).                       
       03  A104008               PIC 9(05).                       
       03  A104009               PIC 9(05).                       
       03  A104010               PIC 9(05).                       
       03  A104011               PIC 9(05).                       
       03  A104012               PIC 9(05).                       
       03  A104013               PIC 9(05).                       
       03  A104014               PIC 9(01).                       
       03  A104015               PIC 9(3)V9(3).                   
       03  A104016               PIC 9(3)V9(3).                   
       03  A104017               PIC 9(3)V9(3).                   
       03  A104018               PIC 9(3)V9(3).                   
       03  A104019               PIC 9(3)V9(3).                   
       03  A104020               PIC 9(3)V9(3).                   
       03  A104021               PIC X(88).                       
 WORKING-STORAGE                 SECTION.                         
 77  LSWI1                    PIC  9(01)  VALUE   0.              
 77  KEYI1                    PIC  9(01)  VALUE   0.              
 77  CTRI1                    PIC S9(15)  COMP-3  VALUE  +0.      
 77  CTRI1R                   PIC S9(15)  COMP-3  VALUE  +0.      
 77  LSWI2                    PIC  9(01)  VALUE   0.              
 77  KEYI2                    PIC  9(01)  VALUE   0.              
 77  CTRI2                    PIC S9(15)  COMP-3  VALUE  +0.      
 77  CTRI2R                   PIC S9(15)  COMP-3  VALUE  +0.      
 77  LSWO1                    PIC  9(01)  VALUE   0.              
 77  KEYO1                    PIC  9(01)  VALUE   0.              
 77  CTRO1                    PIC S9(15)  COMP-3  VALUE  +0.      
 77  CTRO1R                   PIC S9(15)  COMP-3  VALUE  +0.      
 77  LSWO2                    PIC  9(01)  VALUE   0.              
 77  KEYO2                    PIC  9(01)  VALUE   0.              
 77  CTRO2                    PIC S9(15)  COMP-3  VALUE  +0.      
 77  CTRO2R                   PIC S9(15)  COMP-3  VALUE  +0.      
 01  WK-CNT               PIC 9(03).
 01  WK-CNT1              PIC 9(03).
 01  WK-CNT2              PIC 9(03).
 01  WK-CNT3              PIC 9(03).
 01  WK-CNT4              PIC 9(03).
 01  WK-CNT5              PIC 9(03).
 01  WK-CNT6              PIC 9(03).
 01  WK-A103001           PIC 9(03).
 01  WK-A103002           PIC 9(02).
 01  WK-ERR-CD.
     03   ERR-CD-1        PIC 9(01).
     03   ERR-CD-2        PIC 9(01).
     03   ERR-CD-3        PIC 9(01).
     03   ERR-CD-4        PIC 9(01).
     03   ERR-CD-5        PIC 9(01).
     03   ERR-CD-6        PIC 9(01).
     03   ERR-CD-7        PIC 9(01).
 01  WK-ERR-KENSU.
     03   ERR-50          PIC 9(05).
     03   ERR-60          PIC 9(05).
     03   ERR-70          PIC 9(05).
     03   ERR-80          PIC 9(05).
     03   ERR-90          PIC 9(05).
     03   ERR-50Y         PIC 9(05).
     03   ERR-60Y         PIC 9(05).
     03   ERR-70Y         PIC 9(05).
     03   ERR-80Y         PIC 9(05).
     03   ERR-90Y         PIC 9(05).
     03   ERR-50H         PIC 9(05).
     03   ERR-60H         PIC 9(05).
     03   ERR-70H         PIC 9(05).
     03   ERR-80H         PIC 9(05).
     03   ERR-90H         PIC 9(05).
 01  WK-ERR-HASEI.
     03   HASEI-50        PIC 9(3)V9(3).
     03   HASEI-60        PIC 9(3)V9(3).
     03   HASEI-70        PIC 9(3)V9(3).
     03   HASEI-80        PIC 9(3)V9(3).
     03   HASEI-90        PIC 9(3)V9(3).
     03   HASEI-50Y       PIC 9(3)V9(3).
     03   HASEI-60Y       PIC 9(3)V9(3).
     03   HASEI-70Y       PIC 9(3)V9(3).
     03   HASEI-80Y       PIC 9(3)V9(3).
     03   HASEI-90Y       PIC 9(3)V9(3).
     03   HASEI-50H       PIC 9(3)V9(3).
     03   HASEI-60H       PIC 9(3)V9(3).
     03   HASEI-70H       PIC 9(3)V9(3).
     03   HASEI-80H       PIC 9(3)V9(3).
     03   HASEI-90H       PIC 9(3)V9(3).
 LINKAGE                         SECTION.                         
 PROCEDURE                       DIVISION.                        
 000-MAIN-RTN         SECTION.
     DISPLAY  '<<<  START  PRG:AAGC0103  >>>'.
     OPEN             INPUT   FLIN0001
                      OUTPUT  FLOT0001
                      OUTPUT  FLOT0002.
     INITIALIZE       O1.
     INITIALIZE       O2.
     PERFORM  200-SUB-RTN.
     MOVE   A103A01   TO   WK-A103001.
     MOVE   A103A02   TO   WK-A103002.
     IF  LSWI1  NOT =  ZERO
         DISPLAY  '<<<   END   PRG:AAGC0103  >>>'
         CLOSE         FLIN0001
                       FLOT0001
                       FLOT0002
         GO  TO  000-MAIN-RTN-EXT
     END-IF.
     PERFORM UNTIL    LSWI1  NOT =  ZERO
         PERFORM   100-SUB-RTN
     END-PERFORM.
     CLOSE                    FLIN0001
                              FLOT0001
                              FLOT0002.
     DISPLAY  '<<<   END   PRG:AAGC0103  >>>'.
 000-MAIN-RTN-EXT.
     EXIT.
     GOBACK.
 100-SUB-RTN        SECTION.
     IF  A103A01    NOT =   WK-A103001
         ADD   1    TO      WK-CNT1
         PERFORM        110-SUB-RTN
         INITIALIZE     WK-ERR-KENSU   WK-ERR-HASEI
         MOVE   A103A01   TO   WK-A103001
         MOVE   A103A02   TO   WK-A103002
     END-IF.
     MOVE   A103A14     TO   WK-ERR-CD.
     IF  A103A13    =   1  AND
         ERR-CD-4   =   5  OR  6  OR  7  OR  8  OR  9
         PERFORM    300-ERR1-RTN
     END-IF.
     IF  A103A13    =   2  AND
         ERR-CD-4   =   5  OR  6  OR  7  OR  8  OR  9
         PERFORM    300-ERR2-RTN
     END-IF.
     IF  A103A13    =   3  AND
         ERR-CD-4   =   5  OR  6  OR  7  OR  8  OR  9
         PERFORM    300-ERR3-RTN
     END-IF.
     MOVE   I1   TO   O1.
     WRITE       O1.
     PERFORM   200-SUB-RTN.
 100-SUB-RTN-EXT.
     EXIT.
 200-SUB-RTN        SECTION.
               READ    FLIN0001                                   
               AT END  MOVE  1  TO  LSWI1                         
               END-READ                                           
               IF  LSWI1 = 0                                      
                 THEN  ADD   1  TO  CTRI1                         
               END-IF                                             
                   .
     IF  A103A10  =  ZERO
         MOVE  1  TO  A103A10
     END-IF.
     IF  A103A11  =  ZERO
         MOVE  1  TO  A103A11
     END-IF.
     IF  A103A12  =  ZERO
         MOVE  1  TO  A103A12
     END-IF.
 200-SUB-RTN-EXT.
     EXIT.
 300-ERR1-RTN SECTION.
     EVALUATE   ERR-CD-4
        WHEN    5
          ADD   1       TO    ERR-50
        WHEN    6
          ADD   1       TO    ERR-60
        WHEN    7
          ADD   1       TO    ERR-70
        WHEN    8
          ADD   1       TO    ERR-80
        WHEN    9
          ADD   1       TO    ERR-90
     END-EVALUATE.
     COMPUTE  HASEI-50  = (ERR-50 * 100) /
                          (A103A10 + A103A11 + A103A12).
     COMPUTE  HASEI-60  = (ERR-60 * 100) /
                          (A103A10 + A103A11 + A103A12).
     COMPUTE  HASEI-70  = (ERR-70 * 100) /
                          (A103A10 + A103A11 + A103A12).
     COMPUTE  HASEI-80  = (ERR-80 * 100) /
                          (A103A10 + A103A11 + A103A12).
     COMPUTE  HASEI-90  = (ERR-90 * 100) /
                          (A103A10 + A103A11 + A103A12).
 300-ERR1-RTN-EXT.
     EXIT.
 300-ERR2-RTN SECTION.
     EVALUATE   ERR-CD-4
        WHEN    5
          ADD   1       TO    ERR-50
          ADD   1       TO    ERR-50Y
        WHEN    6
          ADD   1       TO    ERR-60
          ADD   1       TO    ERR-60Y
        WHEN    7
          ADD   1       TO    ERR-70
          ADD   1       TO    ERR-70Y
        WHEN    8
          ADD   1       TO    ERR-80
          ADD   1       TO    ERR-80Y
        WHEN    9
          ADD   1       TO    ERR-90
          ADD   1       TO    ERR-90Y
     END-EVALUATE.
     COMPUTE  HASEI-50Y = (ERR-50Y * 100) / A103A11.
     COMPUTE  HASEI-60Y = (ERR-60Y * 100) / A103A11.
     COMPUTE  HASEI-70Y = (ERR-70Y * 100) / A103A11.
     COMPUTE  HASEI-80Y = (ERR-80Y * 100) / A103A11.
     COMPUTE  HASEI-90Y = (ERR-90Y * 100) / A103A11.
 300-ERR2-RTN-EXT.
     EXIT.
 300-ERR3-RTN SECTION.
     EVALUATE   ERR-CD-4
        WHEN    5
          ADD   1       TO    ERR-50
          ADD   1       TO    ERR-50H
        WHEN    6
          ADD   1       TO    ERR-60
          ADD   1       TO    ERR-60H
        WHEN    7
          ADD   1       TO    ERR-70
          ADD   1       TO    ERR-70H
        WHEN    8
          ADD   1       TO    ERR-80
          ADD   1       TO    ERR-80H
        WHEN    9
          ADD   1       TO    ERR-90
          ADD   1       TO    ERR-90H
     END-EVALUATE.
     COMPUTE  HASEI-50H = (ERR-50H * 100) / A103A12.
     COMPUTE  HASEI-60H = (ERR-60H * 100) / A103A12.
     COMPUTE  HASEI-70H = (ERR-70H * 100) / A103A12.
     COMPUTE  HASEI-80H = (ERR-80H * 100) / A103A12.
     COMPUTE  HASEI-90H = (ERR-90H * 100) / A103A12.
 300-ERR3-RTN-EXT.
     EXIT.
 110-SUB-RTN   SECTION.
     OPEN       INPUT    FLIN0002.
     PERFORM         210-SUB-RTN.
     PERFORM   UNTIL   LSWI2  NOT =  ZERO
               ADD     1        TO   WK-CNT2
               IF  A103001    =   WK-A103001
                   PERFORM     111-SUB-RTN
               END-IF
               PERFORM         210-SUB-RTN
     END-PERFORM.
     CLOSE         FLIN0002.
     MOVE   ZERO   TO   LSWI2.
 110-SUB-RTN-EXT.
     EXIT.
 111-SUB-RTN   SECTION.
     ADD     1        TO   WK-CNT.
     EVALUATE        A103013
       WHEN    1
            COMPUTE A104011 = A103010 + A103011 + A103012
            IF     (ERR-CD-4    =      5)  AND
                   (A104011     >     30)  AND
                   (HASEI-50    >     10)
                    PERFORM   200-SYOUKAI-RTN
                    WRITE              O2
            END-IF
            IF     (ERR-CD-4    =      6)  AND
                   (A104011     >     30)  AND
                   (HASEI-60    >     10)
                    PERFORM   200-SYOUKAI-RTN
                    WRITE              O2
            END-IF
            IF     (ERR-CD-4    =      7)  AND
                   (A104011     >     30)  AND
                   (HASEI-70    >     10)
                    PERFORM   200-SYOUKAI-RTN
                    WRITE              O2
            END-IF
            IF     (ERR-CD-4    =      8)  AND
                   (A104011     >     30)  AND
                   (HASEI-80    >     10)
                    PERFORM   200-SYOUKAI-RTN
                    WRITE              O2
            END-IF
            IF     (ERR-CD-4    =      9)  AND
                   (A104011     >     30)  AND
                   (HASEI-90    >     10)
                    PERFORM   200-SYOUKAI-RTN
                    WRITE              O2
            END-IF
       WHEN    2
            IF     (ERR-CD-4    =      5)  AND
                   (A103011     >     10)  AND
                   (HASEI-50Y   >     10)
                    PERFORM   200-YUUSI-RTN
                    WRITE              O2
            END-IF
            IF     (ERR-CD-4    =      6)  AND
                   (A103011     >     10)  AND
                   (HASEI-60Y   >     10)
                    PERFORM   200-YUUSI-RTN
                    WRITE              O2
            END-IF
            IF     (ERR-CD-4    =      7)  AND
                   (A103011     >     10)  AND
                   (HASEI-70Y   >     10)
                    PERFORM   200-YUUSI-RTN
                    WRITE              O2
            END-IF
            IF     (ERR-CD-4    =      8)  AND
                   (A103011     >     10)  AND
                   (HASEI-90Y   >     10)
                    PERFORM   200-YUUSI-RTN
                    WRITE              O2
            END-IF
            IF     (ERR-CD-4    =      9)  AND
                   (A103011     >     10)  AND
                   (HASEI-90Y   >     10)
                    PERFORM   200-YUUSI-RTN
                    WRITE              O2
            END-IF
       WHEN    3
            IF     (ERR-CD-4    =      5)  AND
                   (A103012     >     10)  AND
                   (HASEI-50H   >     10)
                    PERFORM   200-HENSAI-RTN
                    WRITE              O2
            END-IF
            IF     (ERR-CD-4    =      6)  AND
                   (A103012     >     10)  AND
                   (HASEI-60H   >     10)
                    PERFORM   200-HENSAI-RTN
                    WRITE              O2
            END-IF
            IF     (ERR-CD-4    =      7)  AND
                   (A103012     >     10)  AND
                   (HASEI-70H   >     10)
                    PERFORM   200-HENSAI-RTN
                    WRITE              O2
            END-IF
            IF     (ERR-CD-4    =      8)  AND
                   (A103012     >     10)  AND
                   (HASEI-80H   >     10)
                    PERFORM   200-HENSAI-RTN
                    WRITE              O2
            END-IF
            IF     (ERR-CD-4    =      9)  AND
                   (A103012     >     10)  AND
                   (HASEI-90H   >     10)
                    PERFORM   200-HENSAI-RTN
                    WRITE              O2
            END-IF
     END-EVALUATE.
     INITIALIZE       O2.
 111-SUB-RTN-EXT.
     EXIT.
 210-SUB-RTN        SECTION.
               READ    FLIN0002                                   
               AT END  MOVE  1  TO  LSWI2                         
               END-READ                                           
               IF  LSWI2 = 0                                      
                 THEN  ADD   1  TO  CTRI2                         
               END-IF                                             
                   .
     IF  A103010  =  ZERO
         MOVE  1  TO  A103010
     END-IF.
     IF  A103011  =  ZERO
         MOVE  1  TO  A103011
     END-IF.
     IF  A103012  =  ZERO
         MOVE  1  TO  A103012
     END-IF.
     MOVE   A103014     TO   WK-ERR-CD.
     COMPUTE  A104018 = ((A103004 + A103005  +
                          A103006 + A103007  +
                          A103008 + A103009) * 100) /
                         (A103010 + A103011 + A103012).
     COMPUTE  A104019 = ((A103006 + A103007) * 100) /
                          A103011.
     COMPUTE  A104020 = ((A103008 + A103009) * 100) /
                          A103012.
 210-SUB-RTN-EXT.
     EXIT.
 200-SYOUKAI-RTN SECTION.
     ADD      1          TO   WK-CNT4.
     MOVE     A103001    TO   A104001.
     MOVE     A103002    TO   A104002.
     MOVE     A103003    TO   A104003.
     MOVE     A103014    TO   A104004.
     COMPUTE  A104005 =  A103004 + A103006 + A103008.
     COMPUTE  A104006 =  A103005 + A103007 + A103009.
     COMPUTE  A104011 =  A103010 + A103011 + A103012.
     MOVE     A103013    TO   A104014.
     MOVE     10         TO   A104015.
     COMPUTE  A104018 = ((A103004 + A103005  +
                          A103006 + A103007  +
                          A103008 + A103009) * 100) /
                         (A103010 + A103011 + A103012).
 200-SYOUKAI-RTN-EXT.
     EXIT.
 200-YUUSI-RTN SECTION.
     ADD      1         TO   WK-CNT5.
     MOVE    A103001    TO   A104001.
     MOVE    A103002    TO   A104002.
     MOVE    A103003    TO   A104003.
     MOVE    A103014    TO   A104004.
     MOVE    A103006    TO   A104007.
     MOVE    A103007    TO   A104008.
     MOVE    A103011    TO   A104012.
     MOVE    A103013    TO   A104014.
     MOVE    10         TO   A104016.
     COMPUTE  A104019 = ((A103006 + A103007) * 100) /
                          A103011.
 200-YUUSI-RTN-EXT.
     EXIT.
 200-HENSAI-RTN SECTION.
     ADD      1         TO   WK-CNT6.
     MOVE    A103001    TO   A104001.
     MOVE    A103002    TO   A104002.
     MOVE    A103003    TO   A104003.
     MOVE    A103014    TO   A104004.
     MOVE    A103008    TO   A104009.
     MOVE    A103009    TO   A104010.
     MOVE    A103012    TO   A104013.
     MOVE    A103013    TO   A104014.
     MOVE    10         TO   A104017.
     COMPUTE  A104020 = ((A103008 + A103009) * 100) /
                          A103012.
 200-HENSAI-RTN-EXT.
     EXIT.
